﻿using MediatR;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.SheepConditionCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepConditionHandler
{
    public class SheepConditionUpdaHandler : IRequestHandler<SheepConditionUpdaCommand, Results<int>>
    {
        private readonly ISheepConditionService service;

        public SheepConditionUpdaHandler(ISheepConditionService service)
        {
            this.service = service;
        }

        public async Task<Results<int>> Handle(SheepConditionUpdaCommand request, CancellationToken cancellationToken)
        {
            var entity = new SheepCondition
            {
                SheepConditionId = request.SheepConditionId,
                OverBit = request.OverBit,
                SheepConditionSex = request.SheepConditionSex == 1 ? true : false,
                SheepType = request.SheepType,
                CheckDate = request.CheckDate,
                TeethTobite = request.TeethTobite,
                ConditionHair = request.ConditionHair,
                ConditionStain = request.ConditionStain,
                ShoeColor = request.ShoeColor,
                MouthColor = request.MouthColor,
                ConditionCorner = request.ConditionCorner,
                ConditionFat = request.ConditionFat,
                UpdateName = "杨博",
                UpdateTime = DateTime.Now,
                IsDel = 0,
            };
            var list = await service.UpdaSheepCondition(entity);
            return Results<int>.DataResult(list);
        }
    }
}
